<?php include '../templates/choice/common/header.html';?>
<div class="layui-container fly-marginTop">
    <div class="layui-card layui-form-pane">
		<div class="layui-card-header layui-hide-xs">查询订单</div>
		<div class="layui-tab-brief layui-hide-md"><ul class="layui-tab-title"><li class=""><a href="/product/">购买商品</a></li><li class="layui-this">查询订单</li></ul></div>
        <div class="layui-card-body layui-tab layui-tab-brief" lay-filter="user">
			<blockquote class="layui-elem-quote">
				友情提示:订单查询仅能查询最近30天的数据；移动端模式下，仅能查询最近一笔订单。
			</blockquote>
            <div class="layui-tab-content">

						<div class="layui-tab layui-tab-brief" lay-filter="">
							<ul class="layui-tab-title">
								<li class="layui-this">浏览器缓存</a></li>
								<li><a href="/product/query/?zlkbmethod=orderid">订单号</a></li>
								<?php if(isset($config['querycontactswitch']) AND $config['querycontactswitch']>0):?><li><a href="/product/query/?zlkbmethod=contact">联系方式</a></li><?php endif;?>
							</ul>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-show">
									<div class="layui-form-pane" id="query-pane">
										<form class="layui-form" id="query-form">
											<div class="layui-form-item">
												<input type="hidden" name="zlkbmethod" value="cookie">
												<button class="layui-btn" lay-filter="query" lay-submit>查询</button>
											</div>
										</form>
										<div class="layui-table-zlkb">
											<table class="layui-table" style="display: none;" id="query-table">
												<thead><tr><th>订单ID</th><th>订单名称</th><th>数量</th><th>金额</th><th>下单时间</th><th>状态</th></tr></thead>
												<tbody><tr></tr></tbody>
											</table>
										</div>
										<div id="query-ajax-mobile-view"></div>
									</div>
								</div>
							</div>
						</div> 
					

            </div>
        </div>
    </div>
</div>
<!-- cookie tpl-->
<!--引入公共底文件-->
<script src="/res/js/clipboard.min.js"></script>
<?php include '../templates/choice/common/footer.html';?>
<script id="query_ajax_mobile" type="text/html">
{{#  layui.each(d.data, function(index, item){ }}
	{{# if(index ==0){ }}
	<div class="layui-hide-lg layui-hide-md layui-hide-sm">
		<div class="layui-card-header">
		订单信息-{{ converStatus(item.status)}}
		{{#  if(item.status == '0'){ }}
			<button class="layui-btn layui-btn-disabled layui-btn-xs" >未支付订单</button>
		{{# }else if(item.status =="2"){ }}
			<button class="layui-btn layui-btn-xs layui-btn-warm view_kami" id="buy" data-orderid="{{ item.orderid}}">提取卡密</button>
		{{#  } }} 
		</div>
		<div id="prodcut_num">
			<div class="layui-form-item">
				<label class="layui-form-label">订单</label>
				<div class="layui-input-block">
					<input type="text" value="{{ item.orderid}}" readonly disabled class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品</label>
				<div class="layui-input-block">
					<input type="text" value="{{ item.productname}}" readonly disabled class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">数量</label>
				<div class="layui-input-block">
					<input type="text" value="{{ item.number}}" readonly disabled class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">金额</label>
				<div class="layui-input-block">
					<input type="text" value="{{ item.money}}" readonly disabled class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">时间</label>
				<div class="layui-input-block">
					<input type="text" value="{{ createTime(item.addtime)}}" readonly disabled class="layui-input" >
				</div>
			</div>
		</div>
	</div>
	{{#  } }} 
{{#  }); }}
	{{#  if(d.data.length === 0){ }}
		<blockquote class="layui-elem-quote">无数据....</blockquote>
	{{#  } }} 
</script>
<script>
layui.use('productquery');
	function converStatus(status){
		var str = "";
		var s = status;
		switch(s)
		{
			case '0':
				str = '<span class="layui-badge layui-bg-gray">待付款</span>';
				break;
			case '1':
				str = '<span class="layui-badge layui-bg-blue">待处理</span>';
				break;
			case '2':
				str = '<span class="layui-badge layui-bg-green">已完成</span>';
				break;
			default:
				str = '<span class="layui-badge layui-bg-black">处理失败</span>';
				break;
		}
		return str;
	}
    function createTime(v) {
       var date = new Date();
       date.setTime(parseInt(v) * 1000);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		m = m < 10 ? '0' + m : m;
		var d = date.getDate();
		d = d < 10 ? ("0" + d) : d;
		var h = date.getHours();
		h = h < 10 ? ("0" + h) : h;
		var M = date.getMinutes();
		M = M < 10 ? ("0" + M) : M;
		var s = date.getSeconds();
		s = s < 10 ? ("0" + s) : s;
		var str = y + "-" + m + "-" + d + " " + h + ":" + M + ":" + s;
		return str;
	}
</script>